﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

using PotatoSoft.VOCTS.ScriptInterface;
using PotatoSoft.VOCTS.ScriptEngine;

namespace PotatoSoft.Test.ScriptEngineTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            se.DiscOperation = new ImplementationId();
        }

        PotatoSoft.VOCTS.ScriptEngine.ScriptEngine se = new PotatoSoft.VOCTS.ScriptEngine.ScriptEngine();

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (se.RunScript(textBox1.Text))
            {
                MessageBox.Show("Ok");
            }
            else
            {
                MessageBox.Show("Błędy: " + se.GetLastErrors[0]);
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (se.RunScript(new FileInfo("s1.cs")))
            {
                MessageBox.Show("Ok");
            }
            else
            {
                MessageBox.Show("Błędy: " + se.GetLastErrors[0]);
            }
        }
    }

    public class ImplementationId : IDiscOperation
    {
        public bool LoadImage(string filename)
        {
            if (filename == "bla")
                return true;
            else
                return false;
        }
    }
}
